xen/arm: cmpxchg: Provide a new helper that can timeout
authorJulien Grall <julien.grall@arm.com>
Wed, 22 May 2019 20:39:17 +0000 (13:39 -0700)
committerJulien Grall <julien.grall@arm.com>
Fri, 14 Jun 2019 13:27:32 +0000 (14:27 +0100)
commit86b0bc958373217b986ca3fc8c46597577e83049
tree0f8afefdf3d38dc245fbc6be5693ee4824f34027
parent62d10134fb0611bf9d09c6a09877db013e500ea9
xen/arm: cmpxchg: Provide a new helper that can timeout

Exclusive load-store atomics should only be used between trusted
threads. As not all the guests are trusted, it may be possible to DoS
Xen when updating shared memory with guest atomically.

To prevent the infinite loop, we introduce a new helper that can timeout.
The timeout is based on the maximum number of iterations.

It will be used in follow-up patch to make atomic operations on shared
memory safe.

This is part of XSA-295.

Signed-off-by: Julien Grall <julien.grall@arm.com>
Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
Signed-off-by: Stefano Stabellini <stefanos@xilinx.com>
xen/include/asm-arm/arm32/cmpxchg.h
xen/include/asm-arm/arm64/cmpxchg.h